
 //当前班级
 var curclaid='';
 function clopen(classid){
	 curclaid = classid ; 
	 document.getElementById("checkclass").style.display="block";
	 
	 var callbackFun = function(htmlContent){
		 pagecount_classMembers=htmlContent.pc;
		 $("#membercontent").html(""); //清除现有成员信息，防止重复显示
		 $.each(htmlContent.users,function(i,val)
			 {
		 		if(i%2 == 0)
		 			{
		 			$("#membercontent").append('<div class="class_checklist"></div>');
		 			}
		 		$("#membercontent > div:last").append('	<a href="../../home/home/drm_user_zyun.htm">'+
				'<div class="class_checklist01">'+
					'<div class="class_checklist02"> <img src="../images/user02.jpg"/> </div>'+
					val.userName + ' </div>'+
				'</a>');				 	
			 }
			 );
		 refreshpager_classMembers();
	};
	AjaxToolNoEncode("get","/student/class/getStudents",
			{'classid':classid,'pn':pageno_classMembers,'ps':pagesize_classMembers},
			"json",callbackFun);					   
  }

function rep1(c,co){
	  for(var i=1;i<=co;i++){
                if (i==c){
					document.getElementById("replay1"+i).style.display="block";
					}
					else{
						document.getElementById("replay1"+i).style.display="none";
						}
					}
			}
			




function GI(id){
	return document.getElementById(id);
}
function infen(var1){
	var fentip=new Array("","很差，浪费生命","很差，浪费生命","不喜欢","不喜欢","一般，不妨一看","一般，不妨一看","一般，不妨一看","喜欢，值得推荐","喜欢，值得推荐","非常喜欢，不容错过");
	if (var1>0){
		GI("pfno").innerHTML=var1+"分 ";
		GI("pftip").innerHTML=fentip[var1];
		GI("currentrating").style.display="none";
	}
	else{
		GI("pfno").innerHTML="";
		GI("pftip").innerHTML="";
		GI("currentrating").style.display="block";
	}
}

var http_request = false;
function makeRequest(url, functionName, httpType, sendData) {
	http_request = false;
	if (!httpType) httpType = "GET";
	if (window.XMLHttpRequest) { // Non-IE...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/plain');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('无法发送请求，请稍后再试。');
		return false;
	}
	var changefunc="http_request.onreadystatechange = "+functionName;
	eval (changefunc);
	//http_request.onreadystatechange = alertContents;
	http_request.open(httpType, url, true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send(sendData);
}
function getReturnedText () {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var messagereturn = http_request.responseText;
			return messagereturn;
		} else {
			alert('请求出现问题，请稍后再试。');
		}
	}
}
function EchoReturnedText () {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var messagereturn = http_request.responseText;
			if(messagereturn!='isfail'){
				var r;
				r=messagereturn.split('|');
				if(r.length!=1){
					if (r[0]=="8")
					{
						alert("评分成功，感谢您的参与。")
						GI("pfshi").innerHTML=r[1];
						GI("pfge").innerHTML=r[2];
						GI("pfren").innerHTML=r[3];
						GI("currentrating").style.width=r[4]+"px";
					}
				}
				else{
					if (messagereturn=="1")
					{
						alert("您已经参加过该网站的评分。")
					}
					else if (messagereturn=="2")
					{
						alert("评分失败，请稍后再试。")
					}
					else if (messagereturn=="3")
					{
						alert("两次评分间隔时间太短，请稍后再试。")
					}
					else{
						alert(messagereturn);
					}
					//document.getElementById('ajaxarea').innerHTML=messagereturn;
				}
			}
		} else {
			alert('请求出现问题，请稍后再试。');
		}
	}
}



function delnote(note){
note.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(note.parentNode.parentNode.parentNode.parentNode);
alert("笔记已删除！");
}


	
function dels(){
	if( document.getElementById("share01").style.display=="block"){
		document.getElementById("share01").style.display="none";
		document.getElementById("share001").innerHTML="分享";
	}else{
		document.getElementById("share01").style.display="block";
		document.getElementById("share001").innerHTML="取消分享";
	}
}




/***************************************************************************************************/

function    getStudentDiv(tag ){
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	 

	$("#"+tag).parent().find(".agen_left_nav02").removeClass("agen_left_nav02").addClass("agen_left_nav01");

	$("#"+tag).find(".agen_left_nav01").removeClass("agen_left_nav01").addClass("agen_left_nav02");
	
 
	AjaxToolNoEncode("get","/student/"+tag+"/init",{menu:tag},"html",callbackFun);
	
}
function    getContentDiv(tag,action,data){
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	AjaxToolNoEncode("get","/student/"+tag+"/"+action,data,"html",callbackFun);	
}

/**------------------- case---------------------- **/

function querytp(){
	var tp = $("#selectBox option:selected").val();
	getContentDiv('case','init',{'case_tp':tp});  
}
function    addcase(){	
	 $("#caselist").hide();
	$("#beforeadd").show();
}
function accept(){
	getContentDiv('case','accept',null); 
}
function  canceladdcase(){	
	$("#beforeadd").hide();
	$("#caselist").show();
}
function editcase(caseid){
	getContentDiv('case','accept',{'case_id':caseid});
}
function delcase(caseid){
	if(confirm("您确定要删除该案例吗?"))
	{
		var callbackFun = function(htmlContent){
			var result = $.parseJSON(htmlContent);
		if(result.result==1){
				alert('删除成功！');
				$("#case_"+caseid).remove();
			}
		else{
				alert('删除失败!');
			}
		};
		AjaxToolNoEncode("get","/student/case/del",{'caseid':caseid},"text",callbackFun);
		}	
}

function showCasedetail(caseid)
{	
	 var callbackFun = function(htmlContent){	 
		//	var result = $.parseJSON(htmlContent);
		
			if(htmlContent.result){				
				$("#detailtitle").text(htmlContent.result.tilte);
				$("#detailcase_visitor").text(htmlContent.result.case_visitor);
				$("#detailcase_visitor_say").text(htmlContent.result.case_visitor_say);
				//$("#detailcase_handle_content").text(htmlContent.result.case_handle_conten);
				document.getElementById("detailcase_handle_content_ori").innerHTML=htmlContent.result.case_handle_content;
				document.getElementById("detailcase_handle_content").innerHTML=document.getElementById("detailcase_handle_content_ori").innerText;	
				//$("#detailcase_cure_result").html(htmlContent.result.case_cure_result);
				document.getElementById("detailcase_cure_result_ori").innerHTML=htmlContent.result.case_cure_result;
				document.getElementById("detailcase_cure_result").innerHTML=document.getElementById("detailcase_cure_result_ori").innerText;
				$("#casedetail").show();
				}
			else{
					alert('查询失败!');
				}
			};
		AjaxToolNoEncode("get","/student/case/get",{'caseid':caseid},"json",callbackFun);
}

function closeCaseDetail()
{
	 
	$("#casedetail").hide();
}

function savecase(){
	var callbackFun = function(htmlContent){
		//alert('callback');
		getStudentDiv('case');
//		if(htmlContent.length >10)			{
//			$("#contentDiv").html(htmlContent);
//			}
//		else{
//			alert(htmlContent);
//			}
	};
	var case_id = $("#case_id").val();
	 var case_tp = $("#case_tp  option:selected").val();
	 var title = $("#title").val();
	 //alert('title='+title);
	 var case_visitor_say = $("#case_visitor_say").val();
	// var case_handle_content = $("#case_handle_content").val();
	 var case_handle_content = tinymce.get('case_handle_content').getContent();  
	// var case_cure_result = $("#case_cure_result").val();
	 var case_cure_result = tinymce.get('case_cure_result').getContent();  
	 var case_handle_content_id = $("#case_handle_content_id").val();
	 var case_cure_result_id = $("#case_cure_result_id").val();
	 var case_visitor = $("#case_visitor").val();
	var casedata = {'case_id':case_id,'case_tp':case_tp,'title':title,
			'case_visitor_say':case_visitor_say,'case_handle_content':case_handle_content,
			'case_handle_content_id':case_handle_content_id,'case_cure_result_id':case_cure_result_id,
			'case_cure_result':case_cure_result,'case_visitor':case_visitor};
	
	AjaxToolNoEncode("post","/student/case/add",casedata,"json",callbackFun);
	
}

function    getTeacherDiv( tag ){
	 
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	
	$("#"+tag).parent().find(".agen_left_nav02").removeClass("agen_left_nav02").addClass("agen_left_nav01");
	$("#"+tag).find(".agen_left_nav01").removeClass("agen_left_nav01").addClass("agen_left_nav02");
	
	AjaxToolNoEncode("get","/teacher/"+tag+"/init",{menu:tag},"html",callbackFun);
	
}

function	getSudentTabContent(tag, tabId, courseObjId, courseParam, startPage){
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	var startPageParam = 1;
	if(startPage){
		startPageParam = startPage;
	}
	var selectedCourseId = -1;
	if($ ("#" + courseObjId).length>0){
		selectedCourseId =  $('#' + courseObjId).attr('value')
	}else if(courseParam){
		selectedCourseId = courseParam;
	}
	AjaxToolNoEncode("post","/student/"+tag+"/" + tabId + "/" + selectedCourseId + "/" + startPageParam + "/" + QUIZ_PAGE_SIZE,{menu:tag},"html",callbackFun);
}

function	showQuestionDetail(tag, currentTab, questionId, selectedCourseId){
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	AjaxToolNoEncode("post","/student/question/questionView/" + questionId ,{menu:tag, currentTab: currentTab, selectedCourseId: selectedCourseId},"html",callbackFun);
}

/**
 * 发布问题
 * @param objId
 * @param courseObjId
 */
function	postQuestion(objId, courseObjId){
	$.ajax({
		url:"/student/question/postQuestion/" + $('#' + courseObjId).attr('value'),
		type:'post',
		data:{questionContent: $('#' + objId).attr('value')},
		dataType:'html',
		success:function(data,status){
			if(status == "success"){
				var objs = jQuery.parseJSON(data);
				alert(objs.reason);
				if(objs.success == 'true'){
					window.close();
				}
			}
		},
		error:function(xhr,textStatus,errorThrown){
			alert("保存失败， 请重试");
		}
	});
	
}
/**
 * 回复问题
 * @param objId textarea of reply content
 * @param questionId question identification of replay to 
 * @param answerType "T" 为教师, 其他为学生
 */
function 	replyQuestion(tag, currentTab, selectedCourseId, objId, questionId, answerType){
	$.ajax({
		url:"/student/question/replyQuestion/" + questionId + "/" + answerType,
		type:'post',
		data:{answerContent: $('#' + objId).attr('value')},
		dataType:'html',
		success:function(data,status){
			if(status == "success"){
				var objs = jQuery.parseJSON(data);
				alert(objs.reason);
				if(objs.success == 'true'){
					getSudentTabContent(tag, currentTab, 'non-exist-obj', selectedCourseId);
				}
			}
		},
		error:function(xhr,textStatus,errorThrown){
			alert("保存失败， 请重试");
		}
	});
}

/**
 * 我的课程标签切换
 * @param tag
 * @param tabId
 * huangt  2014-12-24
 */
function switchMyCourseTab(tag, tabId){
//	alert(tag);
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	AjaxToolNoEncode("get","/student/"+tag+"/" + tabId + "/0/" + COURSE_PAGE_SIZE,"","html",callbackFun);
}
function getUrlDiv(url){
	var callbackFun = function(htmlContent){
		$("#contentDiv").html(htmlContent);
	};
	AjaxToolNoEncode("get",url,{},"html",callbackFun);
}

